# 定义元组
t1 = (1,"hello",True)
t2 = ()
t3 = tuple()
print(f"t1的类型是：{type(t1)},内容是{t1}")
print(f"t2的类型是：{type(t2)},内容是{t2}")
print(f"t3的类型是：{type(t3)},内容是{t3}")
# 定义单个元素的元素
t4 = ("hello",)# 后面要加上单独的逗号，才算是元组类型
print(f"t4的类型是：{type(t4)},t4的内容是{t4}")

# 元组的嵌套
t5 = ((1,2,3),(4,5,6))
print(f"t5的类型是：{type(t5)},t5的内容是{t5}")

# 下标索引去取出内容
element = t5[1][1]
print(element)


# 元组的操作 index 查找方法
t6 = ("hello","world","python")
index = t6.index("hello")
print(f"在元组t6中查找hello，下标是{index}")

# 元组的操作 count 统计方法
t7 = (1,2,3,4,5,6,7)
num = t7.count(1)
print(f"在元组t7中统计1的数量有{num}")

# 元组的操作 len函数统计元组元素数量
num2 = len(t7)
print(num2)
# 元组的遍历 while 
index = 0
while index<len(t7):
    print(t7[index],end = ' ')
    index+=1
print()
# 元组的遍历 for

for element in t7:
    print(element,end = ' ')
